package com.jy.admins.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jy.common.annotation.Log;
import com.jy.common.core.controller.BaseController;
import com.jy.common.core.domain.AjaxResult;
import com.jy.common.enums.BusinessType;
import com.jy.admins.domain.Admins;
import com.jy.admins.service.IAdminsService;
import com.jy.common.utils.poi.ExcelUtil;
import com.jy.common.core.page.TableDataInfo;

/**
 * 图书馆管理员Controller
 * 
 * @author ruoyi
 * @date 2025-05-30
 */
@RestController
@RequestMapping("/admins/admins")
public class AdminsController extends BaseController
{
    @Autowired
    private IAdminsService adminsService;

    /**
     * 查询图书馆管理员列表
     */
    @PreAuthorize("@ss.hasPermi('admins:admins:list')")
    @GetMapping("/list")
    public TableDataInfo list(Admins admins)
    {
        startPage();
        List<Admins> list = adminsService.selectAdminsList(admins);
        return getDataTable(list);
    }

    /**
     * 导出图书馆管理员列表
     */
    @PreAuthorize("@ss.hasPermi('admins:admins:export')")
    @Log(title = "图书馆管理员", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Admins admins)
    {
        List<Admins> list = adminsService.selectAdminsList(admins);
        ExcelUtil<Admins> util = new ExcelUtil<Admins>(Admins.class);
        util.exportExcel(response, list, "图书馆管理员数据");
    }

    /**
     * 获取图书馆管理员详细信息
     */
    @PreAuthorize("@ss.hasPermi('admins:admins:query')")
    @GetMapping(value = "/{adminId}")
    public AjaxResult getInfo(@PathVariable("adminId") Long adminId)
    {
        return success(adminsService.selectAdminsByAdminId(adminId));
    }

    /**
     * 新增图书馆管理员
     */
    @PreAuthorize("@ss.hasPermi('admins:admins:add')")
    @Log(title = "图书馆管理员", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Admins admins)
    {
        return toAjax(adminsService.insertAdmins(admins));
    }

    /**
     * 修改图书馆管理员
     */
    @PreAuthorize("@ss.hasPermi('admins:admins:edit')")
    @Log(title = "图书馆管理员", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Admins admins)
    {
        return toAjax(adminsService.updateAdmins(admins));
    }

    /**
     * 删除图书馆管理员
     */
    @PreAuthorize("@ss.hasPermi('admins:admins:remove')")
    @Log(title = "图书馆管理员", businessType = BusinessType.DELETE)
	@DeleteMapping("/{adminIds}")
    public AjaxResult remove(@PathVariable Long[] adminIds)
    {
        return toAjax(adminsService.deleteAdminsByAdminIds(adminIds));
    }
}
